﻿package com.bn.NNYY;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
/*
 * 被渔网 捕捉住的鱼的类
 */
public class FishCatched {
	GameView gameview;
	float x;//鱼图片的x坐标
	float y;//鱼图片的y坐标 
	Bitmap[] fish;//鱼的位图
	float degrees;//相对于鱼头向左，旋转的角度
	int i;//鱼尾摆动图片的id
	int space;//鱼重新放在水中时有用
	int fishsign;//大中小鱼的标识位
	public FishCatched(Bitmap[] fish,float x,float y,float degrees,GameView gameview,int space,int fishsign)//随机变换角度时再改
	{
		this.fish=fish;
		this.x=x;//几乎没有用
		this.y=y;
		this.degrees=degrees;
		this.gameview=gameview;
		this.i=0;
		this.space=space;
		this.fishsign=fishsign;
	}
	//绘制被捕捉的鱼的方法
	public void drawSelf(Canvas canvas,Paint paint,float offsetX,float offsetY)
	{
		Matrix m1=new Matrix();//图片旋转一定的角度
		m1.setRotate((float) Math.toDegrees(degrees), fish[i].getWidth()/2, fish[i].getHeight()/2);
		Matrix m2=new Matrix();//图片移动一定的距离
		m2.setTranslate(x+offsetX, y+offsetY);
		Matrix m3=new Matrix();//先移动图片再旋转图片
		m3.setConcat(m2, m1);
		canvas.drawBitmap(fish[i], m3, paint);//绘制旋转后的图片
	}
	public void fishGo()
	{
		this.x=gameview.pointx-Constant.FISHING_NET_WIDTH/4;//这里的几分之几是调出来的，没有理论根据（因为图片有留白）
		this.y=gameview.pointy-Constant.FISHING_NET_HEIGHT/5;
	}
	

}
